package com.sweet.entity;

import com.sweet.enums.MessageType;
import io.vertx.core.json.JsonObject;

/**
 * Created by sweet on 2019/2/13.
 * ---------------------------
 */
public class ServerAckMessage {

  private final String id;

  private final MessageType type;

  public ServerAckMessage(String id, MessageType type) {
    this.id = id;
    this.type = type;
  }

  public static ServerAckMessage create(String id, MessageType type) {
    return new ServerAckMessage(id, type);
  }

  public String toJson() {
    return new JsonObject()
        .put("id", id)
        .put("type", type.name()).encode();
  }

  public String getId() {
    return id;
  }

  public MessageType getType() {
    return type;
  }

  @Override
  public String toString() {
    return "ServerAckMessage{" +
        "id='" + id + '\'' +
        ", type=" + type +
        '}';
  }
}
